clear ;
close all;
BASEDIR = '\\10.12.134.60\linxj\Documents\data\ ';
FRAME_DATA_PATH = fullfile(BASEDIR, 'frame_data\ ');
SCRIPT_PATH = fullfile(BASEDIR, 'sleepstg\script\ ');
% BASEDIR = '/home/linxj/Documents/data/';
% FRAME_DATA_PATH = fullfile(BASEDIR, 'frame_data/');
% SCRIPT_PATH = fullfile(BASEDIR, 'sleepstg/script/');
TYPE_NUM = 5;
FEATURE_NUM = 8;
% load data
wake_feature = load('wake.txt.20131313', '-ascii');
n1_feature = load('n1.txt.20131313', '-ascii');
n2_feature = load('n2.txt.20131313', '-ascii');
n3_n4_feature = load('n3.txt.20131313', '-ascii');
r_feature = load('r.txt.20131313', '-ascii');

feature_cell = {n2_feature n1_feature n3_n4_feature wake_feature r_feature};

%train data
%wake 100 n1 40 n2 100 n3andn4 100 rem 100
train_wake_num = 100;
train_n1_num = 50;
train_n2_num = 100;
train_n3_n4_num = 100;
train_rem_num = 100;
train_cell = {wake_feature(1:train_wake_num, :), n1_feature(1:train_n1_num, :),...
    n2_feature(1:train_n2_num, :), n3_n4_feature(1:train_n3_n4_num, :), r_feature(1:train_rem_num, :)};
train_lable = {ones(train_wake_num, 1), 2 * ones(train_n1_num, 1), ...
    3 *ones(train_n2_num, 1), 4 * ones(train_n3_n4_num, 1), 5 * ones(train_rem_num,1)};
%test data
test_wake_num = 100;
test_n1_num = 20;
test_n2_num = 100;
test_n3_n4_num = 100;
test_rem_num = 50;
test_cell = {n2_feature(train_n2_num + 1 : train_n2_num + test_n2_num, :),n1_feature(train_n1_num + 1 : train_n1_num + test_n1_num, :),n3_n4_feature(train_n3_n4_num + 1: train_n3_n4_num + test_n3_n4_num, :),wake_feature(train_wake_num + 1: train_wake_num + test_wake_num, :),r_feature(train_rem_num + 1 : train_rem_num + test_rem_num, :)};
test_lable = {3 * ones(test_n2_num, 1), 2 * ones(test_n1_num, 1), 4 * ones(test_n3_n4_num, 1), 1 * ones(test_wake_num, 1), 5 * ones(test_rem_num,1)};   
% call DAGSVM
[predict_lable, accurancy ] = DAGSVM(train_lable, train_cell, test_lable, test_cell, TYPE_NUM)
% type maps
type_map = containers.Map;
type_map('w') = 1;
type_map('W') = 1;

type_map('n1') = 2;
type_map('1') = 2;

type_map('n2') = 3;
type_map('2') = 3;

type_map('n3') = 4;
type_map('3') = 4;

type_map('n4') = 4;
type_map('4') = 4;

type_map('r') = 5;
type_map('R') = 5;


% feature extract
%modle = svmtrain(type_array, feature_array,'-s 0 -c 20 -g 0.1')
%svmpredict(pre_type_array, pre_feature_array, modle)
 
 
 
 